]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
calendar: Move handling of ignored events to event source
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 7 Jul 2016 23:04:12 +0000 (01:04 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 8 Jul 2016 13:01:32 +0000 (15:01 +0200)
Ignoring events is currently implemented in the message list's
event section, which means that the calendar does not consider
ignored events when marking days with events. In order to fix
this, move the handling of ignored events to the event source,
which is shared between both components.

https://bugzilla.gnome.org/show_bug.cgi?id=768538

js/ui/calendar.js

index 6e6c5f9b1872254d2580d8cfc39d4f05fda1a6b3..110ff7bf4e0ca6b6fc6eb5427f2b03537b177009 100644 (file)
@@ -120,6 +120,9 @@ const EmptyEventSource = new Lang.Class({
     destroy: function() {
     },
 
+    ignoreEvent: function(event) {
+    },
+
     requestRange: function(begin, end) {
     },
 
@@ -184,6 +187,15 @@ const DBusEventSource = new Lang.Class({
         this.isLoading = false;
         this.isDummy = false;
 
+        this._ignoredEvents = new Map();
+
+        let savedState = global.get_persistent_state('as', 'ignored_events');
+        if (savedState)
+            savedState.deep_unpack().forEach(Lang.bind(this,
+                function(eventId) {
+                    this._ignoredEvents.set(eventId, true);
+                }));
+
         this._initialized = false;
         this._dbusProxy = new CalendarServer();
         this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(object, result) {
@@ -298,6 +310,12 @@ const DBusEventSource = new Lang.Class({
         }
     },
 
+    ignoreEvent: function(event) {
+        this._ignoredEvents.set(event.id, true);
+        let savedState = new GLib.Variant('as', [...this._ignoredEvents.keys()]);
+        global.set_persistent_state('ignored_events', savedState);
+    },
+
     requestRange: function(begin, end) {
         if (!(_datesEqual(begin, this._lastRequestBegin) && _datesEqual(end, this._lastRequestEnd))) {
             this.isLoading = true;
@@ -313,6 +331,10 @@ const DBusEventSource = new Lang.Class({
         let result = [];
         for(let n = 0; n < this._events.length; n++) {
             let event = this._events[n];
+
+            if (this._ignoredEvents.has(event.id))
+                continue;
+
             if (_dateIntervalsOverlap (event.date, event.end, begin, end)) {
                 result.push(event);
             }
@@ -785,15 +807,6 @@ const EventsSection = new Lang.Class({
         this._desktopSettings.connect('changed', Lang.bind(this, this._reloadEvents));
         this._eventSource = new EmptyEventSource();
 
-        this._ignoredEvents = new Map();
-
-        let savedState = global.get_persistent_state('as', 'ignored_events');
-        if (savedState)
-            savedState.deep_unpack().forEach(Lang.bind(this,
-                function(eventId) {
-                    this._ignoredEvents.set(eventId, true);
-                }));
-
         this.parent('');
 
         Shell.AppSystem.get_default().connect('installed-changed',
@@ -802,9 +815,7 @@ const EventsSection = new Lang.Class({
     },
 
     _ignoreEvent: function(event) {
-        this._ignoredEvents.set(event.id, true);
-        let savedState = new GLib.Variant('as', [...this._ignoredEvents.keys()]);
-        global.set_persistent_state('ignored_events', savedState);
+        this._eventSource.ignoreEvent(event);
     },
 
     setEventSource: function(eventSource) {
@@ -850,9 +861,6 @@ const EventsSection = new Lang.Class({
         for (let i = 0; i < events.length; i++) {
             let event = events[i];
 
-            if (this._ignoredEvents.has(event.id))
-                continue;
-
             let message = new EventMessage(event, this._date);
             message.connect('close', Lang.bind(this, function() {
                 this._ignoreEvent(event);